#include "global.h"

long double dis(cv::Point3i p1,cv::Point3i p2)
{
	return (p1.x-p2.x)*(p1.x-p2.x)
		+(p1.y-p2.y)*(p1.y-p2.y)
		+(p1.z-p2.z)*(p1.z-p2.z);
}

long double dis( cv::Point p1,cv::Point p2 )
{
	return (p1.x-p2.x)*(p1.x-p2.x)
		+(p1.y-p2.y)*(p1.y-p2.y);
}

unsigned int getClosestPowerOfTwo( unsigned int n )
{
	unsigned int m = 2;
	while(m < n) m<<=1;

	return m;
}

std::string& replace_all( std::string& str,const std::string& old_value,const std::string& new_value )
{
	while(true)   { 
		std::string::size_type   pos(0); 
		if(   (pos=str.find(old_value))!=std::string::npos   ) 
			str.replace(pos,old_value.length(),new_value); 
		else   break; 
	} 
	return   str;
}
